﻿using System;
using ExFlash.Records;

namespace ExFlash.Tags
{
    public class FrameLabelTag : Tag
    {
        private readonly int _swfVersion;
        
        public StringRecord Name
        {
            get;
            private set;
        }

        public Boolean IsNamedAnchor
        {
            get;
            private set;
        }

        public FrameLabelTag(int len, int version, Int32 offset)
            : base(TagCodes.FrameLabel, len, offset)
        {
            _swfVersion = version;
        }

        public override void SwfDeserialize(BinaryBitReader reader)
        {
            long startIndex = reader.Position;
            
            Name = new StringRecord(_swfVersion);
            Name.SwfDeserialize(reader);

            if ((_swfVersion >= 6) && (reader.Position - startIndex < TagLength))
            {
                IsNamedAnchor = true;
                reader.Position++;
            }
            else
            {
                IsNamedAnchor = false;
            }
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }
    }
}
